{% set pypi_name = 'os-refresh-config' %}
{% set upstream_version = upstream_version('10.4.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name('os-refresh-config', py_versions='py3') }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Refresh system configuration
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('dib-utils') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('psutil') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
Requires:       {{ py3('dib-utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('psutil') }}
BuildArch:      noarch

%description
Tool to refresh openstack config changes to service.

%prep
%autosetup -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

%install
%{py3_install}
install -d -m 755 %{buildroot}%{_libexecdir}/os-refresh-config/pre-configure.d
install -d -m 755 %{buildroot}%{_libexecdir}/os-refresh-config/configure.d
install -d -m 755 %{buildroot}%{_libexecdir}/os-refresh-config/migration.d
install -d -m 755 %{buildroot}%{_libexecdir}/os-refresh-config/post-configure.d

%check
# NOTE(jpena): os_refresh_config.py has a wrong shebang, and it is called
# directly by the tests.
sed -i 's/#!\/usr\/bin\/env.*/#!\/usr\/bin\/python3/' os_refresh_config/os_refresh_config.py
python3 -m stestr.cli run

%files
%license LICENSE
%doc README.rst
%{_bindir}/os-refresh-config
%{python3_sitelib}/os_refresh_config
%{python3_sitelib}/*.egg-info
%{_libexecdir}/os-refresh-config

%changelog
